package com.yhao.controller;

import com.yhao.bean.base.BaseResult;
import com.yhao.exception.BaseException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理
 *
 * @author yhao
 * @create 2017-11-19 13:47
 */

@RestControllerAdvice
public class SpringExceptionHandler {


    @ExceptionHandler(value = BaseException.class)
    public BaseResult errorHandler(BaseException ex) {
        BaseResult baseResult = new BaseResult();
        baseResult.setCode(ex.getCode());
        baseResult.setMassage(ex.getMassage());
        return baseResult;
    }

}
